import com.sap.aii.mapping.api.StreamTransformation;
import com.sap.aii.mapping.api.AbstractTrace;
import com.sap.aii.mapping.api.StreamTransformationConstants;

import java.util.Map;
import java.io.*;

public class MessageDump_warning implements StreamTransformation {
    String strXML = new String();

    AbstractTrace trace;
    private Map param = null;

    public void setParameter(Map param) {
        this.param = param;

    }

    public void execute(InputStream in, OutputStream out) {

        trace =
            (AbstractTrace) param.get(
                StreamTransformationConstants.MAPPING_TRACE);
        trace.addInfo("");

        try {
            StringBuffer strbuffer = new StringBuffer();
            byte[] b = new byte[4096];
            for (int n;(n = in.read(b)) != -1;) {
                strbuffer.append(new String(b, 0, n));
            }
            strXML = strbuffer.toString();
        } catch (Exception e) {
            trace.addWarning("Not possible to retrieve the incoming data; ");
        }
        
        trace.addWarning("Message dump: "+ strXML);
        
        try {
            out.write(strXML.getBytes());
        } catch (Exception e) {
            trace.addWarning("MessageDump_warning.jar: Not possible to output the Services XML; ");
        }
    }   
}
